package com.coffee.mybatis;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.extern.slf4j.Slf4j;

/**
 * 动态命名
 * @author Songkui
 */
@Slf4j
public class CoffeeDynamicTableNameContextHolder {

    /**
     * 动态命名
     */
    private static final ThreadLocal<String> TABLE_NAME = new TransmittableThreadLocal<>();


    /**
     * 动态命名
     * @return 动态命名
     */
    public static String getTableName() {
        return TABLE_NAME.get();
    }

    public static void setTableName(String tableName) {
        TABLE_NAME.set(tableName);
    }

    public static void clear() {
        TABLE_NAME.remove();
    }

}
